<template>
  <view style="width: 100%; min-height: 100vh;">
    <view style="width: 100%; padding-top:  66upx;">
      <view @click="handleBack" style="padding: 0 40upx; margin-bottom: 78upx;">
        <view class="flex align-center" style="font-size: 54upx; color: #999999;">×</view>
      </view>
      <view class="flex flex-direction align-center" style="width: 100%; padding: 0 80upx; margin-bottom: 80upx;">
        <view style="font-weight: bold; margin-bottom: 90upx; text-align: center;">
          <view style="font-size: 40upx; margin-bottom: 20upx;">密码支付</view>
          <view style="font-size: 28upx;" v-if="password_pay_data.fee !== '0.00'">¥{{password_pay_data.fee}}</view>
        </view>
        <view class="flex align-center" style="width: 100%; height: 80upx; border-bottom: 2upx solid #F5F5F5;">
          <input type="password" v-model="password" maxlength="4" placeholder="请输入密码" placeholder-style="color: #DCDCDC;" style="font-size: 28upx; width: 100%;">
        </view>
      </view>
      <view class="flex flex-direction align-center">
        <view @click="handleToPaymentSuccessful()" class="flex align-center justify-center"
              style="width: 596upx; height: 80upx; margin-bottom: 30upx; background-color: #E52718; color: white; font-size: 28upx; border-radius: 40upx;">
          立即支付
        </view>
      </view>
    </view>
  </view>
</template>
<script>
import {a} from "api/pay/pay";

export default {
  data() {
    return {
      password: '', //密码
      password_pay_data: {},//密码支付数据
    }
  },
  methods: {
    //去支付成功页
    handleToPaymentSuccessful(){
      this.password_pay_data.password = this.password;
      if(!this.password){
        uni.showToast({
          title: '请输入密码',
          icon: 'none'
        })
      }
      orders_freeOrPasswordPay(this.password_pay_data).then(res => {
        uni.redirectTo({
          url: `/pages/passBand/paymentSuccessful/paymentSuccessful?fee=${this.password_pay_data.fee}`
        })
      }).catch(err=>{
        console.log(err)
        uni.showToast({
          title: err.msg,
          icon: 'none'
        })
      })
    },
    //返回
    handleBack(){
      uni.navigateBack({
        delta: 1
      });
    },
  },
  onLoad(e){
    e.data = JSON.parse(e.data)
    this.password_pay_data = e.data;
  }
}
</script>
<style lang="less" scoped>
</style>
